//
//  KYPublicServeViewController.m
//  kuaiyi
//
//  Created by 杨亮 on 16/3/17.
//  Copyright © 2016年 kuaiyi. All rights reserved.
//

#import "KYPublicServeViewController.h"
#import "Header.h"
#import "KYPublicHomeView.h"
#import "KYDiseaseClassView.h"
#import "KYPersonInfoView.h"


@interface KYPublicServeViewController ()
@property (nonatomic, strong)UIScrollView *scrollerView;
@end

@implementation KYPublicServeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWith, ScreenHeigth-64)];
    scrollView.contentSize = CGSizeMake(ScreenWith, ScreenHeigth-63);
    [self.view addSubview:scrollView];
    self.scrollerView = scrollView;
    [self chooseSubView:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(chooseSubView:) name:changeViewNotification object:nil];
}
-(void)dealloc{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
-(void)chooseSubView:(NSNotification *)notification{
    [self removeSubViews];
    NSString *notiString = notification.userInfo[changeViewKey];
    UIView *view = nil;
    if (notification == nil) {
        view = [[KYPublicHomeView alloc]init];
    }else{
        if ([notiString isEqualToString:@"applyBtnKlick"]) {
            view = [[KYDiseaseClassView alloc]init];
        }else if ([notiString isEqual:@"classBtnKlick"]){
            view = [[KYPersonInfoView alloc]init];
        }
    }
    view.frame = CGRectMake(0, 0, ScreenWith, self.scrollerView.bounds.size.height);
    [self.scrollerView addSubview:view];
}
-(void)removeSubViews{
    for (UIView *subView in self.scrollerView.subviews) {
        [subView removeFromSuperview];
    }
}
@end
